package com.atguigu.yygh.order.listenler;

import com.atguigu.yygh.consts.MqConst;
import com.atguigu.yygh.order.service.OrderInfoService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/4/3 2:16
 */
@Component
public class OrderReceiver {
    @Autowired
    private OrderInfoService orderInfoService;

    @RabbitListener(bindings = @QueueBinding(
            exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_TASK, type = "direct"),
            value = @Queue(value = MqConst.QUEUE_TASK_8),
            key = MqConst.ROUTING_TASK_8
    ))
    public void receive(Message message, Channel channel) {
            System.out.println("接收到消息：" + message.toString());
            //接受到定时任务,每天8点执行一次
            //去数据库查询订单,不为-1的订单执行短信通知
            orderInfoService.remindSms();
    }
}
